\section{Source/DoublyLinkedList.c}


\begin{footnotesize}\begin{alltt}
00001 \textcolor{preprocessor}{#include "DoublyLinkedList.h"}
00002 
00003 \textcolor{preprocessor}{#ifdef \_\_cplusplus}
00004 \textcolor{preprocessor}{}\textcolor{keyword}{extern} \textcolor{stringliteral}{"C"}
00005 \{
00006 \textcolor{preprocessor}{#endif}
00007 \textcolor{preprocessor}{}
00008 DLL_Element *DLL\_AppendElement(DLL_Element *One, DLL_Element *Two)
00009 \{
00010     Two->Next = NULL;
00011     One->Next = Two;
00012     Two->Previous = One;
00013     \textcolor{keywordflow}{return} One;
00014 \}
00015 
00016 DLL_Element *DLL\_InsertElement(DLL_Element *One, DLL_Element *Two)
00017 \{
00018     DLL_Element *TempPointer = One->Next;
00019     Two->Previous = One;
00020     One->Next = Two;
00021     Two->Next = TempPointer;
00022     TempPointer->Previous = Two;
00023     \textcolor{keywordflow}{return} One;
00024 \}
00025 
00026 DLL_Element *DLL\_GetNthElementFrom(DLL_Element *From, \textcolor{keywordtype}{int} N)
00027 \{
00028     \textcolor{keywordtype}{int} X;
00029     DLL_Element *TempPointer = From;
00030     \textcolor{keywordflow}{for}(X = 0; X < N; ++X)
00031     \{
00032         TempPointer = TempPointer->Next;
00033         \textcolor{keywordflow}{if}(TempPointer == NULL)
00034             \textcolor{keywordflow}{return} NULL;
00035     \}
00036     \textcolor{keywordflow}{return} TempPointer;
00037 \}
00038 
00039 DLL_Element *DLL\_GetNthElementBefore(DLL_Element *Before, \textcolor{keywordtype}{int} N)
00040 \{
00041     \textcolor{keywordtype}{int} X;
00042     DLL_Element *TempPointer = Before;
00043     \textcolor{keywordflow}{for}(X = 0; X < N; ++X)
00044     \{
00045         TempPointer = TempPointer->Previous;
00046         \textcolor{keywordflow}{if}(TempPointer == NULL)
00047             \textcolor{keywordflow}{return} NULL;
00048     \}
00049     \textcolor{keywordflow}{return} TempPointer;
00050 \}
00051 
00052 \textcolor{keywordtype}{int} DLL\_GetSizeFrom(DLL_Element *From)
00053 \{
00054     \textcolor{keywordtype}{int} Size;
00055     DLL_Element *TempPointer;
00056     \textcolor{keywordflow}{for}(TempPointer = From, Size = 0;
00057         TempPointer->Next != NULL;
00058         TempPointer = TempPointer->Next, ++Size);
00059     \textcolor{keywordflow}{return} Size + 1;
00060 \}
00061 
00062 \textcolor{keywordtype}{int} DLL\_GetSizeBefore(DLL_Element *Before)
00063 \{
00064     \textcolor{keywordtype}{int} Size;
00065     DLL_Element *TempPointer;
00066     \textcolor{keywordflow}{for}(TempPointer = Before, Size = 0;
00067         TempPointer->Previous != NULL;  
00068         TempPointer = TempPointer->Previous, ++Size);
00069     \textcolor{keywordflow}{return} Size + 1;
00070 \}
00071 
00072 DLL_Element *DLL\_RemoveElementsBetween(DLL_Element *One, DLL_Element *Two)
00073 \{
00074     One->Next = Two;
00075     Two->Previous = One;
00076     \textcolor{keywordflow}{return} One;
00077 \}
00078 
00079 DLL_Element *DLL\_AppendList(DLL_Element *ListOne, DLL_Element *ListTwo)
00080 \{
00081     ListOne->Next = ListTwo;
00082     ListTwo->Previous = ListOne;
00083     \textcolor{keywordflow}{return} ListOne;
00084 \}
00085 
00086 DLL_Element *DLL\_InsertList(DLL_Element *At, DLL_Element *List)
00087 \{
00088     DLL_Element *TempPointer = At->Next;
00089     At->Next = List;
00090     List->Previous = At;
00091     \textcolor{keywordflow}{while}(List->Next != NULL)
00092         List = List->Next;
00093     List->Next = TempPointer;
00094     TempPointer->Previous = List;
00095     \textcolor{keywordflow}{return} At;
00096 \}
00097 
00098 DLL_Element *DLL\_GetFirstElement(DLL_Element *Element)
00099 \{
00100     \textcolor{keywordflow}{while}(Element->Previous != NULL)
00101         Element = Element->Previous;
00102     \textcolor{keywordflow}{return} Element;
00103 \}
00104 DLL_Element *DLL\_GetLastElement(DLL_Element *Element)
00105 \{
00106     \textcolor{keywordflow}{while}(Element->Next != NULL)
00107         Element = Element->Next;
00108     \textcolor{keywordflow}{return} Element;
00109 \}
00110 
00111 DLL_Element *DLL\_Swap(DLL_Element *A, DLL_Element *B)
00112 \{
00113     DLL_Element *TempPointer = A->Next;
00114     A->Next = B->Next;
00115     B->Next = TempPointer;
00116     TempPointer = A->Previous;
00117     A->Previous = B->Previous;
00118     B->Previous = TempPointer;
00119     \textcolor{keywordflow}{return} A;
00120 \}
00121 
00122 \textcolor{preprocessor}{#ifdef \_\_cplusplus}
00123 \textcolor{preprocessor}{}\}
00124 \textcolor{preprocessor}{#endif}
\end{alltt}\end{footnotesize}
